<?php
namespace app\devel\controller;
use think\Controller;
use app\index\domain as domain;

class Tools extends Controller
{
  	public function __construct()
	{
        parent::__construct();
        if(!APP_DEVEL)
            $this->redirect('/');
    }

    /**
     * 显示首页
     */
    public function index()
    {
        return $this->fetch();
    }

    /**
     * 生成栏目树
     */
    public function createTerm()
    {
        $modelList = $this->createTermModel();
        D('Term')->setModel($modelList);
        $termArr = include(ROOT_PATH.'term.php');
        $create = D('Term')->forAddTerm($termArr, 1);
        if($create !== true)
            dump($create);
        else
            echo "done!";
        return;
    }

    /**
     * 生成模型
     */
    public function createTermModel()
    {
        $termModelArr = include(ROOT_PATH.'term_model.php');
        $create = D('TermModel')->forAdd($termModelArr);
        return $create;
    }
}

